var readyFunc2 = function onBridgeReady() {
    document.querySelector('#closeWindow').addEventListener('click', function(e){
    	WeixinJSBridge.invoke('closeWindow',{
        },function(res){
            
            console.log(res);
 
       });
    });    
    
}


if (typeof WeixinJSBridge === "undefined") {
  document.addEventListener('WeixinJSBridgeReady', readyFunc2, false);
} else {
  readyFunc2();
}
var vm = new Vue({
	el:'#rrapp',
	data:{
		showList: true,
		title:'请完善你的参会信息',
		adduser:{
			name:localStorage.getItem("name"),
			mobile:localStorage.getItem("mobile"),
			
		}
	},
	methods: {
		saveOrUpdate: function () {
			vm.adduser.openid=$('#oid').val();
            if(!$(".form-horizontal").validationEngine("validate")) {
                $(".formError").show();
                return;
            }
           if(vm.validator()){
                return ;
            }
			var url = "../addmtg/addFullInfo";
			$.ajax({
				type: "POST",
			    url: baseURL + url,
                contentType: "application/json",
			    data: JSON.stringify(vm.adduser),
			    success: function(r){
			    	if(r.code === 0){
			    		
			    		parent.location.href='https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ'+'?v='+ new Date().getTime()+Math.random();	
						/*alert('完善您的参会信息通过，隆重有请嘉宾入场！', function(){
							if(is_weixin()){
			    				window.location.href='https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ'+'?v='+ new Date().getTime()+Math.random();	
			    				
			    			}else{
			    				
			    				location.href='https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ'+'?v='+ new Date().getTime()+Math.random();	
			    			}
							//window.location.href='https://mp.weixin.qq.com/s/mSPakDWIF9e4cjHIkfmUSQ'+'?v='+ new Date().getTime()+Math.random();
//							WeixinJSBridge.call('closeWindow');
						});*/
					}else{
						alert(r.msg);
					}
				}
			});
		},
        validator: function () {
            if(isBlank(vm.adduser.name)){
                alert("姓名不能为空");
                return true;
            }else if(vm.adduser.name.search("先生")!=-1||vm.adduser.name.search("小姐")!=-1||vm.adduser.name.search("女士")!=-1){
            	
           	 alert("姓名不能为先生或小姐");
	                return true;
           }
            if(isBlank(vm.adduser.mobile)){
                alert("手机号不能为空");
                return true;
            }
            if(isBlank(vm.adduser.company)){
                alert("公司不能为空");
                return true;
            }
            if(isBlank(vm.adduser.company)){
                alert("职务不能为空");
                return true;
            }

            
        }
	}
});